﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPattern.PrototypePattern
{
    class WorkExperience:ICloneable
    {
        private string timezone;
        private string company;

        public string Timezone
        {
            get { return timezone; }
            set { timezone = value; }
        }

        public string Company
        {
            get { return company; }
            set { company = value; }
        }

        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }

    class Resume:ICloneable
    {
        private string name;
        private string sex;
        private int age;
        private WorkExperience workexp;

        public Resume(string name)
        {
            this.name = name;
            this.workexp = new WorkExperience();
        }

        public Resume(WorkExperience workexp)
        {
            this.workexp = (WorkExperience)workexp.Clone();
        }

        public void SetPersonalInfo(string sex,int age)
        {
            this.sex = sex;
            this.age = age;
        }

        public void SetPersonalInfo(string name,string sex,int age)
        {
            this.name = name;
            this.sex=sex;
            this.age=age;
        }

        public void SetWorkExp(string timezone,string company)
        {
            workexp.Timezone = timezone;
            workexp.Company = company;
        }

        public void Display()
        {
            Console.WriteLine("姓名：{0}\n性别：{1}\n年龄：{2}",name,sex,age);
            Console.WriteLine("工作经历：{0} {1}",workexp.Timezone,workexp.Company);
        }

        public object Clone()
        {
            Resume obj = new Resume(this.workexp);
            obj.name = this.name;
            obj.sex = this.sex;
            obj.age = this.age;
            return obj;
        }
    }
}
